home *** CD-ROM | disk | FTP | other *** search
- /* segment loader:
- public interface definition
- by Cary Clark, Georgiann Delaney, Michael Fairman, Dave Good, Robert Johnson, Keith McGreggor, Oliver Steele, David Van Brink, Chris Yerga
- Copyright 1987 - 1991 Apple Computer, Inc. All rights reserved. */
-
- #ifndef loaderRoutinesIncludes
- #define loaderRoutinesIncludes
-
- #ifndef memoryTypesIncludes
- #include "memory types.h"
- #endif
-
- #ifdef appleInternal
- #ifdef insideLoader
- #define GXInlineCode(x)
- #endif
- #ifndef dontBackpatchSegmentLoader
- #define backpatchSegmentLoader
- #endif
- #endif
- #ifndef GXInlineCode
- #ifdef backpatchSegmentLoader
- #define GXInlineCode(x) = {0x303C, 0x8080 + (x), 0xA832}
- #else
- #define GXInlineCode(x) = {0x303C, 0x8000 + (x), 0xA832}
- #endif
- #endif
-
- #define endOfLoaderReturnStack ((void *)0xFFFFFFFF)
-
- typedef enum {
- returnSegmentSize,
- returnSegmentData,
- returnSegmentCount,
- returnTaskReturnStack
- } segmentSpoolTypes;
-
- typedef long segmentSpoolType;
-
- typedef long (*segmentSpoolFunction)(segmentSpoolType callType, long userReference, long segmentNumber,
- long offset, long size, void *destination);
-
- #ifndef insideLoader
- typedef struct privateLoaderClientRecord *loaderClient;
- #endif
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- /* the system needs to call this routine before making any other segment loader calls. note that there is no shutdown routine */
- void InitializeLoader(void) GXInlineCode(0);
-
- /* these routines allocate and dispose of loader clients */
- loaderClient NewLoaderClient(void *memoryStart, long memoryLength, segmentSpoolFunction spoolFunc,
- long userReference) GXInlineCode(1);
- void DisposeLoaderClient(loaderClient client) GXInlineCode(2);
-
- /* these routines return the non-modifiable fields of a loaderClient */
- void *GetLoaderClientGlobals(loaderClient client) GXInlineCode(3);
- void *GetLoaderClientGlobalsStart(loaderClient client) GXInlineCode(4);
- gxHeap *GetLoaderClientHeap(loaderClient client) GXInlineCode(5);
-
- /* these routines get and set the modifiable fields of a loaderClient */
- long GetLoaderClientUserReference(loaderClient client) GXInlineCode(6);
- void SetLoaderClientUserReference(loaderClient client, long newRef) GXInlineCode(7);
- segmentSpoolFunction GetLoaderClientSpoolFunction(loaderClient client) GXInlineCode(8);
- void SetLoaderClientSpoolFunction(loaderClient client, segmentSpoolFunction newFunc) GXInlineCode(9);
-
- /* these must be switched at process switch time if several processes are using the loaderClient */
- void *GetLoaderClientReturnStack(loaderClient client) GXInlineCode(10);
- void SetLoaderClientReturnStack(loaderClient client, void *newStack) GXInlineCode(11);
- void *GetLoaderClientLastBlock(loaderClient client) GXInlineCode(12);
- void SetLoaderClientLastBlock(loaderClient client, void *lastBlock) GXInlineCode(13);
-
- /* this routine disposes of all the unlocked segments in the loaderClient’s code gxHeap */
- void FlushLoaderSegments(loaderClient client) GXInlineCode(14);
-
- /* this routine loads the segment that contains the function pointed to by address, locks this segment down and makes
- it permanent by patching the jump table to jump straight into it. this segment can never be moved or disposed of after
- this, since the segment loader no longer has any way of knowing whether some process is currenly executing in it or
- not */
-
- void LoadPermanentSegment(void *address) GXInlineCode(15);
-
- /* this routine aborts all the functions entered in the return stack from its current position back to the passed saveStack
- value. the lockCounts for all these functions will be updated properly and the returnStack and lastBlock will be restored */
-
- void CleanupLoaderReturnStack(loaderClient client, void *savedStack) GXInlineCode(16);
-
- /* these routines lock and unlock access to the loader client’s code gxHeap. the first one also sets the busy counts for code blocks correctly */
- void LockLoaderClientMemory(loaderClient client) GXInlineCode(17);
- void UnlockLoaderClientMemory(loaderClient client) GXInlineCode(18);
-
- /* this routine validates the passed loaderClient to ensure that it is a loaderClient and it hasn’t been damaged */
- void ValidateLoaderClient(loaderClient client) GXInlineCode(19);
-
- /* this returns the size of the patchRecord that Patch and Unpatch LoaderClientFunction use */
- long GetLoaderClientPatchSize(void) GXInlineCode(20);
-
- /* you must call these routines to create and destroy patch records for jump table entries */
- void *PatchLoaderClientFunction(loaderClient client, short functionA5Offset, void *patchAddress) GXInlineCode(21);
- void UnpatchLoaderClientFunction(loaderClient client, void *patchAddress) GXInlineCode(22);
-
- /* once the patch record has been created, these functions allow jump table entries to be redirected */
- void *GetLoaderClientFunction(loaderClient client, short functionA5Offset) GXInlineCode(23);
- void SetLoaderClientFunction(loaderClient client, short functionA5Offset, void *newAddress) GXInlineCode(24);
-
- #ifdef __cplusplus
- }
- #endif
-
- #undef GXInlineCode
-
- #endif
-